package org.kernely.ui.profile;

import org.kernely.ui.MainApplication;
import org.kernely.ui.mvp.IKernelyView;
import org.kernely.ui.mvp.KernelyEventSender;

import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;

/**
 *	View of the Kernely public profile.
 */
@SuppressWarnings("serial")
public class KernelyPublicProfileView extends VerticalLayout implements IKernelyView, KernelyEventSender {

	private Label title;
	private Label civilityLabel;
	private Label nameLabel;
	private Label firstnameLabel;
	private Embedded pictureEmbedded;
	private Label descriptionLabel;
	private Label phoneLabel;
	private Label emailLabel;
	private Label addressLabel;
	private Label skypeLabel;
	private Label linkedInLabel;
	private Label twitterLabel;
	private Label viadeoLabel;
	
	private Label socialTitle;
	private Label socialSeparator;
	
	/**
	 * KernelyPublicProfileView constructor.
	 */
	public KernelyPublicProfileView(){

		title = new Label(); // Filled in the presenter
		title.setStyleName(Reindeer.LABEL_H1);
		title.setSizeUndefined(); // Usefull to center the label.
		
		VerticalLayout vlayout = new VerticalLayout();
		Panel headerPanel = new Panel();		
		headerPanel.setContent(vlayout);
		vlayout.addComponent(title);
		vlayout.setMargin(true, false, true, false);
		vlayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER);
		headerPanel.setSizeFull();


		// Personnal informations
		Label generalTitle = new Label("General informations");
		generalTitle.setStyleName(Reindeer.LABEL_H2);
		
		civilityLabel = new Label("",Label.CONTENT_XHTML);
		
		nameLabel = new Label("",Label.CONTENT_XHTML);
		firstnameLabel = new Label("",Label.CONTENT_XHTML);

		// Picture
		Label pictureTitle = new Label("Picture");
		pictureTitle.setStyleName(Reindeer.LABEL_H2);
		pictureEmbedded = new Embedded();
		pictureEmbedded.setHeight(100,Sizeable.UNITS_PIXELS);
		pictureEmbedded.setWidth(100,Sizeable.UNITS_PIXELS);
		pictureEmbedded.setImmediate(true);

		// About
		descriptionLabel = new Label("",Label.CONTENT_XHTML);;
		
		// Contact
		Label contactTitle = new Label("Contact");
		contactTitle.setStyleName(Reindeer.LABEL_H2);
		emailLabel = new Label("",Label.CONTENT_XHTML);;
		phoneLabel = new Label("",Label.CONTENT_XHTML);;
		addressLabel = new Label("",Label.CONTENT_XHTML);;
		skypeLabel = new Label("",Label.CONTENT_XHTML);;
		
		// Social networks
		socialSeparator = new Label("<hr/>",Label.CONTENT_XHTML);
		socialTitle = new Label("Social networks");
		socialTitle.setStyleName(Reindeer.LABEL_H2);
		
		linkedInLabel = new Label("",Label.CONTENT_XHTML);;
		twitterLabel = new Label("",Label.CONTENT_XHTML);;
		viadeoLabel = new Label("",Label.CONTENT_XHTML);;
		
		Panel mainPanel = new Panel();
		
		mainPanel.addComponent(generalTitle);
		mainPanel.addComponent(civilityLabel);
		mainPanel.addComponent(nameLabel);
		mainPanel.addComponent(firstnameLabel);
		mainPanel.addComponent(descriptionLabel);
		mainPanel.addComponent(new Label("<hr/>",Label.CONTENT_XHTML));
		mainPanel.addComponent(pictureTitle);
		mainPanel.addComponent(pictureEmbedded);
		mainPanel.addComponent(new Label("<hr/>",Label.CONTENT_XHTML));
		mainPanel.addComponent(contactTitle);
		mainPanel.addComponent(emailLabel);
		mainPanel.addComponent(phoneLabel);
		mainPanel.addComponent(skypeLabel);
		mainPanel.addComponent(addressLabel);
		mainPanel.addComponent(socialSeparator);
		mainPanel.addComponent(socialTitle);
		mainPanel.addComponent(viadeoLabel);
		mainPanel.addComponent(linkedInLabel);
		mainPanel.addComponent(twitterLabel);
		
		
		this.addComponent(headerPanel);
		this.addComponent(mainPanel);


		this.setSpacing(true);

	}
	
	/**
	 * Gets the title lable
	 * @return the title label
	 */
	public final Label getTitleLabel() {
		return title;
	}
	
	/**
	 * Gets the civilityLabel
	 * @return the civilityLabel
	 */
	public Label getCivilityLabel() {
		return civilityLabel;
	}

	
	
	/**
	 * Gets the nameLabel
	 * @return the nameLabel
	 */
	public Label getNameLabel() {
		return nameLabel;
	}

	/**
	 * Gets the firstnameLabel
	 * @return the firstnameLabel
	 */
	public Label getFirstnameLabel() {
		return firstnameLabel;
	}

	/**
	 * Gets the pictureEmbedded
	 * @return the pictureEmbedded
	 */
	public Embedded getPictureEmbedded() {
		return pictureEmbedded;
	}

	/**
	 * Gets the descriptionLabel
	 * @return the descriptionLabel
	 */
	public Label getDescriptionLabel() {
		return descriptionLabel;
	}

	/**
	 * Gets the phoneLabel
	 * @return the phoneLabel
	 */
	public Label getPhoneLabel() {
		return phoneLabel;
	}

	/**
	 * Gets the emailLabel
	 * @return the emailLabel
	 */
	public Label getEmailLabel() {
		return emailLabel;
	}

	/**
	 * Gets the addressLabel
	 * @return the addressLabel
	 */
	public Label getAddressLabel() {
		return addressLabel;
	}

	/**
	 * Gets the skypeLabel
	 * @return the skypeLabel
	 */
	public Label getSkypeLabel() {
		return skypeLabel;
	}

	/**
	 * Gets the linkedInLabel
	 * @return the linkedInLabel
	 */
	public Label getLinkedInLabel() {
		return linkedInLabel;
	}

	/**
	 * Gets the twitterLabel
	 * @return the twitterLabel
	 */
	public Label getTwitterLabel() {
		return twitterLabel;
	}

	/**
	 * Gets the viadeoLabel
	 * @return the viadeoLabel
	 */
	public Label getViadeoLabel() {
		return viadeoLabel;
	}

	
	
	
	/**
	 * Gets the title of the social section
	 * @return the label of the title
	 */
	public Label getSocialTitle() {
		return socialTitle;
	}

	

	/**
	 * Gets the socialSeparator
	 * @return the socialSeparator
	 */
	public Label getSocialSeparator() {
		return socialSeparator;
	}

	/**
	 * This method is called when this component is added to an other.
	 */
	@Override
	public final void attach(){
		super.attach();
		//When the component is attached, we fire listeners
		MainApplication.getEventBus().broadcastEvent(new KernelyPublicProfileAttachedEvent(this));
	}
	
	/**
	 * Unused method.
	 */
	@Override
	public Component getComponent() {
		return this;
	}

	
	
}
